package com.hthy.futures.ui.fragment;

import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.LinearLayout;

import com.hthy.futures.R;
import com.hthy.futures.base.BaseFragment;
import com.hthy.futures.utils.AnimationLoader;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * 密码修改
 * Author:  Mr.bingley
 * Version:
 * Date:  2017/3/6
 */

public class UpdatepwdFragment extends BaseFragment {

    private TradePwdFragment mTradePwdFragment;
    private FundPwdFragment mFundPwdFragment;
    private FragmentTransaction mTransaction;

    @Bind(R.id.fragment_container1)
    LinearLayout mFramentContainer1;

    @Bind(R.id.fragment_container2)
    LinearLayout mFramentContainer2;

    @Override
    protected int getLayoutId() {
        return R.layout.frag_update_pwd;
    }

    @Override
    protected void initWidget(View root) {
        super.initWidget(root);
        mFramentContainer1.setVisibility(View.GONE);
        mFramentContainer2.setVisibility(View.GONE);
    }

    @OnClick({R.id.ll_sell,R.id.ll_fund})
    public void onClick(View view) {
        mTransaction = getChildFragmentManager().beginTransaction();   // 不能定义在外部为成员变量位置，
        hideFrament();
        switch (view.getId()) {
            case R.id.ll_sell:
                AnimationLoader.magiceShow2(getActivity(), mFramentContainer1);
                if (mTradePwdFragment == null) {
                    mTradePwdFragment = new TradePwdFragment();
                    mTransaction.add(R.id.fragment_container1, mTradePwdFragment);
                }
                mTransaction.show(mTradePwdFragment);
               // SlideCotainerActivity.gotoActivity(getActivity(), 4);

                mFramentContainer1.setVisibility(View.VISIBLE);
                mFramentContainer2.setVisibility(View.GONE);
                break;
            case R.id.ll_fund:
                AnimationLoader.magiceShow2(getActivity(), mFramentContainer2);
                if (mFundPwdFragment == null) {
                    mFundPwdFragment = new FundPwdFragment();
                    mTransaction.add(R.id.fragment_container2, mFundPwdFragment);
                }
                mTransaction.show(mFundPwdFragment);
                //SlideCotainerActivity.gotoActivity(getActivity(), 5);
                mFramentContainer1.setVisibility(View.GONE);
                mFramentContainer2.setVisibility(View.VISIBLE);
                break;
        }
        mTransaction.commit();
    }

    private void hideFrament() {
        if (mTradePwdFragment != null) {
            mTransaction.hide(mTradePwdFragment);
        }
        if (mFundPwdFragment != null) {
            mTransaction.hide(mFundPwdFragment);
        }
    }
}
